<include file="public@header" />
</head>
<body>
<script type="text/html" id="photos-item-tpl">
    <li id="saved-image{id}">
        <input id="photo-{id}" type="hidden" name="photo_urls[]" value="{filepath}">
        <input class="form-control" id="photo-{id}-name" type="text" name="photo_names[]" value="{name}"
               style="width: 200px;" title="图片名称">
        <img id="photo-{id}-preview" src="{url}" style="height:36px;width: 36px;"
             onclick="imagePreviewDialog(this.src);">
        <a href="javascript:uploadOneImage('图片上传','#photo-{id}');">替换</a>
        <a href="javascript:(function(){$('#saved-image{id}').remove();})();">移除</a>
    </li>
</script>

<div class="wrap js-check-wrap">
		<ul class="nav nav-tabs">
			<li><a href="{:url('user/index')}">员工管理</a></li>
			<li class="active"><a href="javascript:;">员工编辑</a></li>
		</ul>
	<form method="post" class="form-horizontal js-ajax-form margin-top-20" action="{:url('user/editPost')}">
    <input type="hidden" name="id" value="{$id}" />
		 <div class="row">
		 <div class="col-md-9">
		  <table class="table table-bordered">
  	        <tr>
                <th style="width: 170px"><span class="form-required">*</span>{:lang('USERNAME')}</th>
                <td>
                   <input type="text" class="form-control" id="input-user_login" name="post[user_login]" value="{$user_login}" required="required">
                </td>
            </tr>
            <tr>
                <th style="width: 170px">手机号码</th>
                <td>
                   <input type="text" class="form-control"  name="post[mobile]" value="{$mobile}">
                </td>
            </tr>
            <if condition="cmf_get_current_admin_id() eq 1">
            <tr>
                <th style="width: 170px">{:lang('PASSWORD')}</th>
                <td>
                    <input type="password" class="form-control" id="input-user_pass" name="user_pass" placeholder="******" value="">
                </td>
            </tr>
            <tr>
                <th style="width: 170px">重复密码</th>
                <td>
                    <input type="password" class="form-control" id="input-d_pass" name="d_pass" value="">
                </td>
            </tr>
            </if>
            <tr>
                <th style="width: 170px">{:lang('EMAIL')}</th>
                <td>
                    <input type="text" class="form-control" id="input-user_email" name="post[user_email]" value="{$user_email}">
                </td>
            </tr>
            <tr>
                <th>角色</th>
                <td>
                    <select class="form-control" name='role_id'>{$roleList}</select>
                    <input type="hidden" name="company_id" value="{$company['id']}">
                </td>
            </tr>
			</table>
      <!--角色弹窗-->
      <div id="roleselect_tc" style="display: none;">
          <div id="roleselect_list" style="margin: 5px;"></div>
      </div>
			<div class="form-group">
  				<div class="col-sm-offset-2 col-sm-10">
                <button type="submit" class="btn btn-primary js-ajax-submit">提交</button>
  				</div>
			</div> 
		</div>		
    <div class="col-md-3">
        <table class="table table-bordered">
            <tr>
                <th><b>头像上传</b></th>
            </tr>
            <tr>
                <td>
                    <div style="text-align: center;">
                        <input type="hidden" name="post[avatar]" id="thumbnail" value="{$avatar}">
                        <a href="javascript:uploadOneImage('图片上传','#thumbnail');">
                              
                                  <if condition="empty($avatar)">
                                <img src="__TMPL__/public/assets/images/default-thumbnail.png"
                                     id="thumbnail-preview"
                                     width="135" height="130"  style="cursor: pointer;border-radius: 50%"/>
                                <else/>
                                <img src="{:cmf_get_image_preview_url($avatar)}"
                                     id="thumbnail-preview"
                                     width="130" height="130" style="cursor: pointer;border-radius: 50%"/>
                            </if>
                                 
                        </a>
                        <input type="button" class="btn btn-sm btn-cancel-thumbnail" value="取消图片">
                    </div>
                </td>
            </tr>
        </table>
    </div>
	</div>
	</form>
	
	</div>
<script type="text/javascript">
    $(function () {
        editorcontent = new baidu.editor.ui.Editor();
        editorcontent.render('content');
        try {
            editorcontent.sync();
        } catch (err) {
        }
        $('.btn-cancel-thumbnail').click(function () {
            $('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
            $('#thumbnail').val('');
        });

    });
</script>
<script src="__STATIC__/js/admin.js"></script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript" src="__STATIC__/js/layer/layer.js"></script>
<script src="__STATIC__/js/zy-treeview/zy-treeview.1.0.js"></script>


<script  type="text/javascript">

$(function(){
  var role=JSON.parse('{$role}');
  console.log(role);
  $('select[name=role_id] option').each(function(){
    if($(this).value==role.id){
      $(this).prop('selected',true);
      return false;
    }
  });
});
</script>
</body>
</html>